print("sample4")
-- Update_mode 更新模式，默认为 Update_mode.Immediately 立即更新
-- NextTick下一帧更新
-- OnFree闲时更新
-- onGet不主动更新，只在bind属性被获取时更新
local role = Observable({atk = 10})
Bind(role, "atk_final", function()
    local atk = role.atk + (role.pet and role.pet.atk or 0)
    print('atk change', atk)
    return atk
end, Update_mode.OnFree)

-- print(role2.atk_final)

local pet = Observable({atk = 11})
role.pet = pet
-- print(role2.atk_final)
UpdateObservers()
UpdateObservers()
UpdateObservers()
UpdateObservers()
UpdateObservers()